﻿using System.Collections;

namespace Map_Creator.RedoUndo.Actions
{
    class ListInsertAction : IAction
    {
        private IList list;
        private int index;
        private object item;

        public ListInsertAction(IList list, int index, object item)
        {
            this.list = list;
            this.index = index;
            this.item = item;
        }

        public void Do()
        {
            list.Insert(index,item);
        }

        public void Undo()
        {
            // Better by item or by index?!
            list.RemoveAt(index);
        }

        public string GetDescription()
        {
            return "Inserting " + item + " Into List";
        }

        public string GetName()
        {
            return "List Insert";
        }
    }
}
